<template>
  <div>
    <el-form
      :inline="true"
      :model="formInline"
      class="demo-form-inline"
      style="text-align: left"
    >
      <el-form-item>
        <el-form-item label="培训名称">
          <el-input
            v-model="formInline.tilite"
            placeholder="培训名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="文档类型">
          <el-select v-model="formInline.document" placeholder="请选择文档类型">
            <el-option label="请选择" value=""></el-option>
            <el-option label="视频教程" value="1"></el-option>
            <el-option label="文档教程" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-button
          style="background-color: green; color: white"
          icon="el-icon-search"
          @click="list"
          >查询</el-button
        >
        <el-button style="color: gray" icon="el-icon-refresh">重置</el-button>
        <el-button style="color: green" @click="add">新增</el-button>
      </el-form-item>
    </el-form>
    <el-form :inline="true" class="demo-form-inline" style="text-align: left">
      <el-form-item>
        <el-button
          class="size-icon"
          type="text"
          style="color: green"
          icon="el-icon-s-unfold"
          @click="train"
        ></el-button>
      </el-form-item>
      <el-form-item>
        <el-button
          class="size-icon"
          type="text"
          style="color: green"
          icon="el-icon-menu"
          @click="trainCard"
        ></el-button>
      </el-form-item>
    </el-form>
    <el-row>
      <el-col
        :span="8"
        v-for="(o, index) in tableData"
        :key="o"
        :offset="index > 0 ? 2 : 0"
      >
        <el-card :body-style="{ padding: '0px' }">
          <div style="padding: 14px">
            <h2 style="color: green">{{ o.tilite }}</h2>
            <el-divider></el-divider>
            <br />
            <br />
            <i class="el-icon-document"></i><b>文档类型:{{ o.tilite }}</b>
            <br />
            <br />
            <i class="el-icon-circle-check"></i><b>学习时长:{{ o.learning }}</b>
            <br />
            <br />
            <i class="el-icon-time"></i><b>添加时间:{{ o.addtime }}</b>
            <br />
            <br />
            <i class="el-icon-star-off"></i
            ><b
              >学习人数:<el-button
                style="background-color: green; color: white"
                >{{ o.study }}</el-button
              ></b
            >
            <br />
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="formInline.pageIndex"
      :page-sizes="[1, 2, 3, 4]"
      :page-size="formInline.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="countnum"
    >
    </el-pagination>
  </div>
</template>
<script>
import { GetShowTrain, GetTotaocount } from "@/api/SafeManage/Train";
export default {
  data() {
    return {
      currentDate: new Date(),
      tableData: [],
      formInline: {
        pageIndex: 1,
        pageSize: 2,
        tilite: "",
        document: "",
      },
      countnum: 0,
      count: 0,
    };
  },
  created() {
    this.list();
    this.totalcount();
  },
  methods: {
    //显示
    list() {
      GetShowTrain(this.formInline).then((res) => {
        this.tableData = res.data.data;
        this.count = res.data.totalCount;
      });
    },
    handleSizeChange(val) {
      this.formInline.pageSize = val;
      this.list();
    },
    handleCurrentChange(val) {
      this.formInline.pageIndex = val;
      this.list();
    },
    totalcount() {
      GetTotaocount().then((res) => {
        this.countnum = res.data;
      });
    },
    //跳转
    add() {
      this.$router.push("/SafeManage/AddTrain");
    },
    //列表
    train() {
      this.$router.push("/SafeManage/Train");
    },
    //卡片
    trainCard() {
      this.$router.push("/SafeManage/TrainCard");
    },
  },
};
</script>
<style>
.size-icon {
  font-size: 30px;
}
.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}
</style>